#include <iostream>
#include <vector>
using namespace std;

//99.85%
class Solution
{
  public:
	int removeDuplicates(vector<int> &nums)
	{
		int k = 1, sign = 0;
		if (!nums.size())
			return 0;
		for (int i = 1; i < nums.size(); i++)
			if (nums[i] != nums[i - 1])
			{
				nums[k++] = nums[i];
				sign = 0;
			}
			else if (sign == 0)
			{
				nums[k++] = nums[i];
				sign = 1;
			}
		return k;
	}
};

int main()
{
	int nums[9] = {0, 0, 1, 1, 1, 1, 2, 3, 3};
	int len = sizeof(nums) / sizeof(int);
	vector<int> myVector(nums, nums + len);
	len = Solution().removeDuplicates(myVector);
	for (int i = 0; i < len - 1; i++)
	{
		cout << myVector[i] << " ";
	}
	cout << myVector[len - 1] << endl;
	return 0;
}
